Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
Need to get each "link" entry from nested json using js

There is a json code. Consisting by type: {"123":{...},"321":{...}} In it, you need to get "links" from each entry. I couldn't understand this note, please help me.

{
"3782474584475521065": {
    "listingid": "3782474584475521065",
    "price": 16,
    "asset": {
        "currency": 0,
        "appid": 730,
        "contextid": "2",
        "id": "25996697315",
        "amount": "1",
        "market_actions": [
            {
                "link": "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D2354938592644984102",
                "name": "Осмотреть в игре…"
            }
        ]
    }
},
"3782474584475520325": {
    "listingid": "3782474584475520325",
    "price": 16,
    "asset": {
        "currency": 0,
        "appid": 730,
        "contextid": "2",
        "id": "25996698023",
        "amount": "1",
        "market_actions": [
            {
                "link": "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D9866835690490179400",
                "name": "Осмотреть в игре…"
            }
        ]
    }
}

}

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

If I understood your question correctly, you need to extract the links from the json text. This is a solution:

const a = {
  "3782474584475521065": {
    listingid: "3782474584475521065",
    price: 16,
    asset: {
      currency: 0,
      appid: 730,
      contextid: "2",
      id: "25996697315",
      amount: "1",
      market_actions: [
        {
          link: "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D2354938592644984102",
          name: "Осмотреть в игре…",
        },
      ],
    },
  },
  "3782474584475520325": {
    listingid: "3782474584475520325",
    price: 16,
    asset: {
      currency: 0,
      appid: 730,
      contextid: "2",
      id: "25996698023",
      amount: "1",
      market_actions: [
        {
          link: "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D9866835690490179400",
          name: "Осмотреть в игре…",
        },
      ],
    },
  },
};

// get links from a
const links = Object.values(a).map(({ asset }) => {
  const { market_actions } = asset;
  const { link } = market_actions[0];
  return link;
});

console.log(links);

This simply iterates through the object's values and accesses the link values through object extraction.

about 4 years ago · Juan Pablo Isaza Report

0

Return an array of objects {id:link}

const data = {
  "3782474584475521065": {
    "listingid": "3782474584475521065",
    "price": 16,
    "asset": {
      "currency": 0,
      "appid": 730,
      "contextid": "2",
      "id": "25996697315",
      "amount": "1",
      "market_actions": [
          {
              "link": "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D2354938592644984102",
              "name": "Осмотреть в игре…"
          }
      ]
    }
  },
  "3782474584475520325": {
    "listingid": "3782474584475520325",
    "price": 16,
    "asset": {
      "currency": 0,
      "appid": 730,
      "contextid": "2",
      "id": "25996698023",
      "amount": "1",
      "market_actions": [
          {
              "link": "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D9866835690490179400",
              "name": "Осмотреть в игре…"
          }
      ]
    }
  }
}
const result = Object.entries(data).map(([key, {asset, ...rest}]) => ({[key]: asset.market_actions[0].link}))
console.log(result)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!